home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr11 / ddj9304.zip / OS2WPS.ZIP / INSTALL.C next >
C/C++ Source or Header  |  1993-01-18  |  2KB  |  50 lines

  1. [LISTING FIVE]
  2.  
  3. // install.c -- installation program for spreadsheet app
  4. //  compile and link with: icc /Ss /Ti install.c
  5.  
  6. #define INCL_WINWORKPLACE
  7. #include <os2.h>
  8. int main ( int argc, char *argv[] )
  9. {
  10.     HAB     hab;                    // anchor block
  11.     HOBJECT hobjFolder;             // folder object
  12.     HOBJECT hobjProg;               // program object
  13.     BOOL    fSuccess;               // return from API
  14.   // create an anchor block so we can retrieve errors
  15.     hab = WinInitialize ( 0 );
  16.   // create a folder on the desktop for our program object
  17.     hobjFolder = WinCreateObject ( "WPFolder", "My Folder" 
  18.               , "OBJECTID=<MY_FOLDER>" , "<WP_DESKTOP>" , CO_REPLACEIFEXISTS );
  19.     if ( hobjFolder == NULLHANDLE )
  20.     {
  21.         ULONG   ul;             // error code
  22.         ul = WinGetLastError ( hab );
  23.         printf ("Unable to create folder, error = %x\n", ERRORIDERROR ( ul ) );
  24.     }
  25.   // register our object class for our data files
  26.     fSuccess = WinRegisterObjectClass ( "WPSpread" 
  27.                                        , "c:\\book\\wpsart\\wpspread.dll" );
  28.     if ( fSuccess == FALSE )
  29.     {
  30.         ULONG   ul;             // error code
  31.         ul = WinGetLastError ( hab );
  32.         printf ("Unable to register class, error = %x\n",
  33.                 ERRORIDERROR ( ul ) );
  34.     }
  35.   // create a program object for our EXE file
  36.     hobjProg = WinCreateObject ( "WPProgram", "Spreadsheet App"
  37.                     , "EXENAME=c:\\book\\wpsart\\spread.exe;"
  38.                       "ASSOCTYPE=XX Company Spreadsheet,,;"
  39.                       "ASSOCFILTER=*.SPR,," , "<MY_FOLDER>"
  40.                     , CO_REPLACEIFEXISTS );
  41.     if ( hobjProg == NULLHANDLE )
  42.     {
  43.         ULONG   ul;             // error code
  44.         ul = WinGetLastError ( hab );
  45.         printf ("Unable to create program object, error = %x\n",
  46.                 ERRORIDERROR ( ul ) );
  47.     }
  48.     WinTerminate ( hab );
  49. }
  50.